<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>cisau信院免费邮--校园邮箱第一品牌</title>
<link rel="shortcut icon" href="<%=basePath %>images/favicon.ico" type="image/x-icon"/>

  <link rel="stylesheet" href="<%=basePath %>js/jPlayer/jplayer.flat.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/bootstrap.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/animate.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/font-awesome.min.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/simple-line-icons.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/font.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/app.css" type="text/css" />  
</head>
<script type="text/javascript" src="<%=basePath %>js/jquery.min.js"></script>
<body class="">
<jsp:include page="top.jsp"></jsp:include>
  <section class="vbox">
    
        <!-- /.aside -->
        <section id="content">
          <section class="vbox bg-white">
            <header class="header bg-light lter hidden-print">
              <a href="#" class="btn btn-sm btn-info pull-right" onClick="window.print();">Print</a>
              <p>草稿箱</p>
            </header>
            <section class="scrollable wrapper">
              
                   <i class="fa fa-file-text" style="font-size:20px;"></i>

              <p class="m-t m-b">草稿箱数量：<strong id="draftNum"></strong>封<br>
                  
              </p>
              <div class="line"></div>
              <table class="table">
                <thead>
                  <tr>
                    <th style="width: 60px">QTY</th>
                    <th style="width: 75%">主题</th>
                    
                    <th style="text-align: center;">创建时间</th>
                    <th style="text-align: center;">编辑发送</th>
                    <th style="text-align: center;">删除</th>
                    
                  </tr>
                </thead>
                <tbody id="myDraftList">
                  
                  
                </tbody>
              </table>              
            </section>
          </section>
          <a href="#" class="hide nav-off-screen-block" data-toggle="class:nav-off-screen,open" data-target="#nav,html"></a>
        </section>
      </section>
    </section>    
  </section>
<script src="<%=basePath %>js/wizard/jquery.bootstrap.wizard.js"></script>
<script src="<%=basePath %>js/wizard/demo.js"></script>
  <script src="<%=basePath %>js/app.plugin.js"></script>
  <script type="text/javascript" src="<%=basePath %>js/jPlayer/jquery.jplayer.min.js"></script>
  <script type="text/javascript" src="<%=basePath %>js/jPlayer/add-on/jplayer.playlist.min.js"></script>
  <script type="text/javascript" src="<%=basePath %>js/jPlayer/demo.js"></script>
</body>
<script>
$(document).ready(function(){
	showAll();
});
	function showAll(){
		debugger;
		var l = document.getElementById("myDraftList");
		var draftNum = document.getElementById("draftNum");
		draftNum.innerHTML='';
		l.innerHTML='';
		var everything = document.getElementById("everything").value;
		$.ajax( {
						url:'<%=basePath%>email/findAllDraft',
						type:'post',
						data: {
							
						},
						datatype : "json",//"xml", "html", "script", "json", "jsonp", "text".           
						success : function(data) {
							var json=eval('(' + data + ')');
							
							var num = Object.keys(json).length;
							$("#draftNum").append(num);
							$.each(json, function (n, item) {
								if(item.sendMan.indexOf(everything)>=0||item.title.indexOf(everything)>=0||item.content.indexOf(everything)>=0){
									addDraftList(n,item);
								}						
							});
						},
						error : function() {
			                alert("异常！！！");
			            }
				});
	}
	function addDraftList(n,item){
		
		
		var val = "<tr>"+
            "<td>"+(n+1)+"</td>"+
            "<td>"+item.title+"</td>"+
            "<td style=\"text-align: center;\">"+item.createTime+"</td>"+
            
            "<td style=\"width: 120px;text-align: center;\"><a href=\"../email/selDraftDetail?id="+item.id+"\"><i class=\"fa fa-paste\"></i></a></td>"+
            "<td style=\"text-align: center;\"><a href=\"javascript:delDraft('"+item.id+"');\"><i class=\"fa fa-fire\"></i></a></td>"+
            		"</tr>";
            
            
		
		
		$("#myDraftList").append(val);
	}
	
	function outOfBlackList(id,flag){
		debugger;

		$.ajax( {
			url:'<%=basePath%>friend/editBlackList',
			type:'post',
			data: {
				id:id,
			},
			datatype : "text",//"xml", "html", "script", "json", "jsonp", "text".           
			success : function(data) {
				
				showAll();		
			},
			 error : function() {
                 alert("异常！");
                 showAll();	
             }
		});
	}
	function delDraft(id){
		debugger;

		$.ajax( {
			url:'<%=basePath%>email/delDraft',
			type:'post',
			data: {
				id:id,
			},
			datatype : "json",//"xml", "html", "script", "json", "jsonp", "text".           
			success : function(data) {
				
				showAll();			
			},
			 error : function() {
                 alert("异常！");
                 showAll();		
             }
		});
	}
	
	
	
</script>
</html>